package com.tc.util;

import com.alibaba.fastjson.JSONObject;
import entity.Result;
import org.apache.tomcat.util.json.JSONParser;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import tk.mybatis.mapper.MapperException;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public class ServerEncoder implements Encoder.Text<Result>{
    @Override
    public String encode(Result object) throws EncodeException {
        try {
            return JSONObject.toJSONString(object);
        } catch (MapperException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }
}
